package com.xsoft.sms.cmpp20.msg;

import com.xsoft.sms.cmpp20.message.impl.CMPP20Message;

import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * package: {PACKAGE_NAME}
 * User: zhanglm
 * Date: 12-9-18
 * Time: 下午2:15
 * Description:
 */
public class SmsMsg {
	private int seqId;
	private long msgId;
	private byte[] msgContent;
	private String[] destination;
	private byte msgFormat;
	private AtomicInteger sendCount;
	private Long timestamp;

	public SmsMsg(int seqId, byte[] msgContent, String[] destination) {
		this(seqId, msgContent, destination, CMPP20Message.CMPP20_DEFAULT_MSG_FMT);
	}

	public SmsMsg(int seqId, byte[] msgContent, String[] destination, byte msgFormat) {
		this.seqId = seqId;
		this.msgId = 0;
		this.msgContent = msgContent;
		this.destination = destination;
		this.msgFormat = msgFormat;
		this.sendCount = new AtomicInteger(0);
		this.timestamp = new Date().getTime() / 1000;
	}

	public void updateTimestamp() {
		this.timestamp = new Date().getTime() / 1000;
	}

	public int updateSendCount() {
		return this.sendCount.incrementAndGet();
	}

	public int getSeqId() {
		return seqId;
	}

	public void setSeqId(int seqId) {
		this.seqId = seqId;
	}

	public long getMsgId() {
		return msgId;
	}

	public void setMsgId(long msgId) {
		this.msgId = msgId;
	}

	public byte[] getMsgContent() {
		return msgContent;
	}

	public void setMsgContent(byte[] msgContent) {
		this.msgContent = msgContent;
	}

	public String[] getDestination() {
		return destination;
	}

	public void setDestination(String[] destination) {
		this.destination = destination;
	}

	public byte getMsgFormat() {
		return msgFormat;
	}

	public void setMsgFormat(byte msgFormat) {
		this.msgFormat = msgFormat;
	}

	public Long getTimestamp() {
		return timestamp;
	}

	public int getSendCount() {
		return sendCount.get();
	}

}
